from functools import total_ordering

from utils.log import Log


@total_ordering
class RawObject(Log):
    def __init__(self, val, asc=True):
        super(RawObject, self).__init__()
        self.val = val
        self.asc = asc

    def __repr__(self):
        return f"{self.val}"

    def __lt__(self, other):
        if isinstance(other, self.__class__):
            if self.asc:
                return self.val < other.val
            else:
                return self.val > other.val
        else:
            self.simple_error("Incorrect attribute!")

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.val == other.val
        else:
            self.simple_error("Incorrect attribute!")

    def __hash__(self):
        return hash(self.val)

    def __int__(self):
        return int(self.val)

    def __neg__(self):
        return RawObject(-self.val, self.asc)


if __name__ == '__main__':
    o1 = RawObject(1)
    o2 = RawObject(2)
    print(o1 < o2, o1 == o2, o1 > o2)
